package com.yuandengta.yomall.coupon.controller;

import com.yuandengta.common.utils.R;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/*
*
* 动态 获取 nacos 里面的配置
* */
@RefreshScope
@RestController
@RequestMapping("coupon/coupon")
public class CouponController {

    @Value("${coupon.user.name}")
    private String name;
    @Value("${coupon.user.url}")
    private String url;

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id) {
        return R.ok().put("data", "hello" + id);
    }

    /**
     * 测试动态配置功能
     *
     * @return
     */
    @RequestMapping("/testConfig")
    public R testConfg() {
        return R.ok().put("name", name).put("url", url);
    }


}
